home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 737 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: solon.com!not-for-mail
  2. From: spc@gate.net (Sean 'Captain Napalm' Conner)
  3. Newsgroups: comp.std.c,comp.lang.c.moderated
  4. Subject: Re: printf() format extensions - looking for beta testers...
  5. Date: 13 Apr 1996 08:58:47 -0500
  6. Organization: CyberGate, Inc.
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4kobun$8i2@solutions.solon.com>
  10. References: <4kgljv$l2p@solutions.solon.com> <4klicn$ndl@solutions.solon.com> <4kll9l$o5h@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4kll9l$o5h@solutions.solon.com> seebs@taniemarie.solon.com (Peter Seebach) writes:
  14.  >In article <4klicn$ndl@solutions.solon.com>,
  15.  >Ari Lukumies  <aril@cmt.lpr.mail.carel.fi> wrote:
  16.  >>Peter Seebach wrote:
  17.  >> >         int bangcvt(va_list *ap, char *s, int len, fmtspec *f) {
  18.  >> >                 strncpy(s, strerror(errno), len);
  19.  >> >                 s[len - 1] = '\0';
  20.  >> >                 return strlen(s);
  21.  >> >         }
  22.  >
  23.  >>Given the above, how about calls like (well, not a pretty one, but you get the 
  24.  >>idea...):
  25.  >
  26.  >>    fprintf(stderr, "%-*.2!", something);
  27.  >
  28.  >This would call
  29.  >    bangcvt(&ap, buf, len, { '!', something, 2, FMT_LEFT });
  30.  >and leave the interpretation of the width and precision up to bangcvt.
  31.  >flags are or'ed together.
  32.  >
  33.  >It might not work correctly; I think my sample implementation may have a bug
  34.  >in handling flags.  The principle is as given, though.
  35.  >
  36.   But there is a potential problem with doing this.  What if you use a
  37. pre-compiled module that has extended printf(), say, using '%#' (unbeknownst
  38. to you, the documentation may be a bit lax (happens enough)).  What happens
  39. when you try to extend printf() using '%#'?  With possible different
  40. semantics (different type, say)?
  41.  
  42.   -spc (Or does your printf() report a redefinition error?)
  43.